﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.Domain;
using Kooboo.IoC;

namespace Kooboo.Commerce.Domain.Services
{
    public class ShippingService:ServiceBase<IShippingRepository,IShipping>
    {
        //internal ShippingService()
        //{
        //}

        public override IQueryable<IShipping> QueryService
        {
            get {
                return this.Repository.Shippings;
            }
        }

        public void Post(IShipping shipping)
        {
            

            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Post(shipping);


                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Put(IShipping shipping)
        {
            


            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Put(shipping);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Delete(IShipping shipping)
        {
            

            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Delete(shipping);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }
    }

}
